<!DOCTYPE html>
<html lang="zh-CN">
	<head>
		<meta charset="utf-8" />
		<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable = no">
		<title></title>
		<link rel="stylesheet" type="text/css" href="../_public/css/css.css">
		<script type="text/javascript" src="../_public/js/jquery-2.1.4.min.js"></script>
		<script type="text/javascript" src="../_public/js/tigerUI_640.js"></script>
		<style type="text/css">
			div{
				font-size:.26rem;
			}
		</style>
	</head>
	<body>
		<div id="isLine">-</div>
		
		<div id="dTextX">-</div>
		<div id="dTextY">-</div>
		<div id="dTextZ">-</div>
		<div id="tl1">-</div>
		<div id="tl2">-</div>
		<div id="tl3">-</div>
		<div id="d8">0</div>
		<div id="d9">0</div>
		<div id="d10">0</div>
		<div id="d1">0</div>
		<div id="d2">0</div>
		<div id="d3">0</div>
		<script>
			//震动API
			// navigator.vibrate = navigator.vibrate || navigator.webkitVibrate || navigator.mozVibrate || navigator.msVibrate;
			// navigator.vibrate(1000);
			// console.log(navigator.vibrate);
			//网络监听
			if (navigator.onLine) {
				$("#isLine").html("当前设备在线");
				// console.log(navigator);
				// console.log(navigator.connection);
				// console.log(navigator.webkitConnection);
				// console.log(navigator.mozConnection);
			} else {
				$("#isLine").html("当前设备离线");
			}
			window.addEventListener('offline', function(e) {
				$("#isLine").html("当前设备离线");
			});
			window.addEventListener('online', function(e) {
				$("#isLine").html("当前设备在线");
			});
			//陀螺
			window.addEventListener("deviceorientation", function(event) {
				var x = parseFloat(event.alpha).toFixed(2);
		        var y = parseFloat(event.beta).toFixed(2);
		        var z = parseFloat(event.gamma).toFixed(2);
		        $("#tl1").html("（陀螺传感）alpha:"+x);
		        $("#tl2").html("（陀螺传感）beta:"+y);
		        $("#tl3").html("（陀螺传感）gamma:"+z);
			}, false);
			//感应
			window.addEventListener("devicemotion", devicemotion, false);
		    function devicemotion(event) { 
	
		        var accelerationIG = event.accelerationIncludingGravity;
		        var xg = parseFloat(accelerationIG.x).toFixed(1);
		        var yg = parseFloat(accelerationIG.y).toFixed(1);
		        var zg = parseFloat(accelerationIG.z).toFixed(1);
		        
		        if(xg > 0){
		        	$("#dTextX").html("（重力传感）+右偏:"+Math.abs(xg*10));
		        }else{
		        	$("#dTextX").html("（重力传感）-左偏:"+Math.abs(xg*10));
		        }
	
		        if(yg > 0){
		        	$("#dTextY").html("（重力传感）+前仰:"+Math.abs(yg*10));
		        }else{
		        	$("#dTextY").html("（重力传感）-后仰:"+Math.abs(yg*10));
		        }
	
		        if(zg > 0){
		        	$("#dTextZ").html("（重力传感）+屏幕向下:"+Math.abs(zg*10));
		        }else{
		        	$("#dTextZ").html("（重力传感）-屏幕向上:"+Math.abs(zg*10));
		        }
	
		        var acceleration_ = event.acceleration;
		        var x = parseFloat(acceleration_.x).toFixed(2);
		        var y = parseFloat(acceleration_.y).toFixed(2);
		        var z = parseFloat(acceleration_.z).toFixed(2);
		        $("#d8").html("（加速传感）位移速度X:"+x);
		        $("#d9").html("（加速传感）位移速度Y:"+y);
		        $("#d10").html("（加速传感）位移速度Z:"+z);
	
		        // var timer = event.interval;
		        // $("#d4").html("间隔时间:"+parseInt(timer));
	
		        var rotate = event.rotationRate;
		        $("#d1").html("（加速传感）X旋转速度gamma:"+parseInt(rotate.gamma));
		        $("#d2").html("（加速传感）Y旋转速度beta:"+parseInt(rotate.beta));
		        $("#d3").html("（加速传感）Z旋转速度alpha:"+parseInt(rotate.alpha));
		    }
		</script>
	</body>
</html>